<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background-color: black;
        }
    </style>
</head>

<body>
    <div class="box"></div>
    <script>
        let box = document.querySelector('.box')

        box.addEventListener('click', function () {
            box.style.display = 'none';
            box.style.width = 200 + 'px';
            console.log(box.offsetWidth);

            box.style.width = 300 + 'px';
            console.log(box.offsetWidth);

            box.style.width = 400 + 'px';
            console.log(box.offsetWidth);

            box.style.width = 50 + 'px';
            console.log(box.offsetWidth);
            box.style.display = 'block';
        })
    </script>
</body>

</html>